<?php

require_once 'modules/content/models/Content.php';
require_once 'modules/content/models/ContentCategory.php';
require_once 'modules/mail/models/Mail.php';
require_once 'modules/user/models/User.php';
class content_IndexController extends Nine_Controller_Action
{
	public function indexAction()
	{
		/**
		 * Set template
		 */
		$templatePath  = Nine_Registry::getModuleName() . '/views/templates/default';
		$templatePath .= '/index.' . Nine_Constant::VIEW_SUFFIX;
		$this->view->html = $this->view->render( $templatePath );
	}
	
	public function detailAction()
	{
		$objContent = new Models_Content();
		$objContentCategory = new Models_ContentCategory();
		
		$gid = $this->_getParam('id',false);
//        echo $gid ;die;
		$alias = $this->_getParam('alias',false);
		if ( false == $gid) {
			if (false == $alias) {
				$this->_redirectToNotFoundPage();
			}
			else {
				$news = @reset($objContent->getByColumns(array('alias=?' => $alias))->toArray());
			}
		}
		else {
			$news = $objContent->getContentByGid($gid)->toArray();
		}
		if (null == $news) {
			$this->_redirectToNotFoundPage();
		}
		
        $this->view->news = $news;
        $this->view->headTitle($news['title']);
        
		if($gid == 1 || $alias == "fresher"){
        	$this->view->menuId = array('fresher', 'fresher_introduction');
       		$this->view->image = "front/images/upload/img_left_2.jpg";
			$this->view->title = 'FRESHER&nbsp;&nbsp;>&nbsp;<span>GIỚI THIỆU</span>';
        }
        elseif($gid == 5 || $alias == "gioi-thieu"){
        	$this->view->menuId = array('internship', 'internship_introduction');
       		$this->view->image = "front/images/upload/img_left_5.jpg";
			$this->view->title = 'THỰC TẬP&nbsp;&nbsp;>&nbsp;<span>GIỚI THIỆU</span>';
        }
		elseif($gid == 7 || $alias == "gioi-thieu-tour"){
			$this->view->title = 'VNG TOUR&nbsp;&nbsp;>&nbsp;<span>GIỚI THIỆU</span>';
        	$this->view->menuId = array('vng_tour', 'vng_tour_introduction');
       		$this->view->image = "front/images/upload/img_left_4.jpg";
        }  
        elseif($gid == 13 || $alias == "about-us"){
        	$this->view->menuId = array('home', '');
       		$this->view->image = "front/images/upload/img_left_2.jpg";
        }         
		elseif($gid == 19 || $alias == "phuc-loi"){
			$this->view->title = 'FRESHER&nbsp;&nbsp;>&nbsp;<span>PHÚC LỢI</span>';
        	$this->view->menuId = array('fresher', 'fresher_recruitment');
        	$this->view->image = "front/images/upload/img_left_8.jpg";
        }  
        elseif($gid == 21 || $alias == "chuong-trinh-dao-tao"){
        	$this->view->title = 'FRESHER&nbsp;&nbsp;>&nbsp;<span>CHƯƠNG TRÌNH ĐÀO TẠO</span>';
        	$this->view->menuId = array('fresher', 'fresher_training');
        	$this->view->image = "front/images/upload/img_left_9.jpg";
        }  
        elseif($gid == 17 || $alias == "cam-nhan-fresher"){
        	$this->view->title = 'FRESHER&nbsp;&nbsp;>&nbsp;<span>CẢM NHẬN FRESHER</span>';
        	$this->view->menuId = array('fresher', 'fresher_typical_face');
        	$this->view->image = "front/images/upload/img_left_10.jpg";
        }  
        $templatePath  = Nine_Registry::getModuleName() . '/views/templates/default';
		$templatePath .= '/detail.' . Nine_Constant::VIEW_SUFFIX;
		
		
		
		$this->view->html = $this->view->render( $templatePath );
        
	}
	
	private function _redirectToNotFoundPage()
	{
	    $this->_redirect("");
	}
}